using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

using OpenSim.Region.ClientStack.FunSLUDP;

class MyFirstBot
{
    public void Test(string url, string first_name, string last_name, string password)
    {
        uint code;
        string agentID, sessionID;

        FunSL sim=new FunSL();
        sim.Login(url, first_name, last_name, password, out code, out sessionID, out agentID);
        sim.Connect(url);

        byte[] packet=sim.GetPacket();

        SLPacket.UseCircuitCodeHeader(packet);
        SLPacket.UseCircuitCode_CircuitCode(packet, code, sessionID, agentID);
        sim.SendOutgoingPacket(packet, SLPacket.UseCircuitCodeLength(packet));

        SLPacket.CompleteAgentMovementHeader(packet);
        SLPacket.CompleteAgentMovement_AgentData(packet, agentID, sessionID, code);
        sim.SendOutgoingPacket(packet, SLPacket.CompleteAgentMovementLength(packet));

        int length;
        sim.GetIncomingPacket(packet, out length, 0);
        Console.WriteLine("Got packet {0}", SLPacket.Header.GetPacketID(packet));
        sim.ReturnPacket(packet);

        sim.Disconnect();
    }


    public static void Main()
    {
        MyFirstBot bot=new MyFirstBot();
        bot.Test("http://localhost:9000", "test", "user", "test");
    }

}
 
